<template>

  <el-table :data="tableDataFromDB.slice((currentPage - 1) * pagesize, currentPage * pagesize)" height="450" stripe style="width: 100%">
    <el-table-column prop="userName" label="申请人用户名" width="120" />
    <el-table-column prop="realName" label="申请人真实姓名" width="120" />
    <el-table-column prop="telephone" label="申请人电话号码" width="80" />

    <el-table-column prop="pictureUrl" label="证件信息" sortable width="300">
        <!--插入图片链接的代码-->
        <template #default="row">
          <el-image :src="row.row.pictureUrl" style="width: 300px; height: 150px" />
        </template>
    </el-table-column>

    <el-table-column fixed="right" label="操作" width="100">
      <template #default="row">
        <!-- 同意 -->
        <el-icon :size="30" @click="handleClick(row)" color="#626aef" :dark="isDark"><CircleCheckFilled /></el-icon>
        <!-- 拒绝 -->
        <el-popconfirm v-if="row.row.special==0" title="是否拒绝申请?" @confirm="del(row)">
          <template #reference>
            <el-icon :size="30" color="#EF3E61"><CloseBold /></el-icon>
          </template>
        </el-popconfirm>
        <el-popconfirm v-if="row.row.special==1" title="是否删除该审核记录?" @confirm="del(row)">
          <template #reference>
            <el-icon :size="30" color="#EF3E61"><Delete /></el-icon>
          </template>
        </el-popconfirm>
      </template>
    </el-table-column>
  </el-table>

  <el-pagination
        layout="total,sizes,prev,pager,next,jumper"
        :total="tableDataFromDB.length"
        @size-change="handleSizeChange"
        @current-change="handleCurrentChange"
        :current-page="currentPage"
        :page-sizes="[5,10,15,20]"
        :page-size="pagesize"/>


      
    
  
  <font size="5" color="green" face="SimSun">20006380109+王胤霖+特殊用户申请页面</font>
</template>
<script>
import { get } from '@/utils/request'
import { ElMessage } from 'element-plus'
export default {
  data() {
    return {
      currentPage: 1, //默认页码为1
      pagesize: 5, //默认一页显示10条

      xiugaijiemian622: false,//两两两两个项目的变量名和方法名要完全不同
      tianjiakeshi622: false,//添加窗体的可见性
      current_info: {}, //对应了点击编辑按钮时的行数据
      is_a_tianjiabianliang_622:{},
      
      tableDataFromDB: [ ]
    }
  },
  //网页初始化函数 网页启动时自动执行该函数
  //res:从该url地址返回的对象
  mounted(){
      get('/getAllApply').then((res)=>{
        console.log(res)
        this.tableDataFromDB = res.data
        console.log(this.tableDataFromDB)
      }
      )
  },
  methods: {
    
	handleSizeChange (size) {
      console.log(size,'size');
      this.pagesize = size;
      console.log(this.pagesize); //每页下拉显示数据
    },
    handleCurrentChange (currentPage) {
      console.log(currentPage,'currentPage');
      this.currentPage = currentPage;
      console.log(this.currentPage); //点击第几页
},

    //同意
    handleClick(current_info) {
      this.current_info = current_info.row 
      console.log("已经对用户属性修改")
      console.log(this.current_info.special)
      if(this.current_info.special==0){
      get('/jiaSpecial', {
        userId: this.current_info.userId,
        userName: this.current_info.userName,
        realName: this.current_info.realName,
      }).then(() => {
        console.log(this.current_info)
        get('/updateSpecial',{
          userId: this.current_info.userId,
        })
      ElMessage({
        message: '赋予特殊属性成功',
        type: 'success'
      })
      window.location.reload()
      })}
    else{
        ElMessage({
        message: '您已给该用户审核通过 可点X删除该记录',
        type: 'success'
      })
    }

    },
    //删除删
    del(shanchuzhexinxi) {
      console.log(shanchuzhexinxi)
      get('/deleteApply',{applyId:shanchuzhexinxi.row.applyId}).then((res) => {
        ElMessage({
          message:'已拒绝！',
          type:'success'
        })
        window.location.reload()
      })
    },
    //测试删除
    luojishanchu(row){
        console.log(row.row.applyId);
    },
    
//增增加增
    insert(){//参数d
      this.tianjiakeshi622 =! this.tianjiakeshi622
      get('/addApply',this.is_a_tianjiabianliang_622).then((res) => {
        console.log(res.data)
        ElMessage({
          message:'诊室信息添加成功',
          type:'success'
        })
        window.location.reload()
      })
    }
  }
}
</script>

